package com.example.mycomposelearing

import android.content.res.Resources

/**
 *@Author tgw
 *@Date 2023/08/15
 *@describe
 */

val Int.pxToDp: Int
    get() = (this / Resources.getSystem().displayMetrics.density + 0.5f).toInt()

val Int.dp: Int
    get() = (this * Resources.getSystem().displayMetrics.density + 0.5f).toInt()

/**
 * 转sp
 */
val Int.sp: Int
    get() = (this * Resources.getSystem().displayMetrics.scaledDensity + 0.5f).toInt()
